package ct.zxd.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ct.zxd.utils.KdApiSearchDemo;

/**
 * Servlet implementation class GetLogistics
 */
public class GetLogistics extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setCharacterEncoding("UTF-8");
        response.setContentType("text/json;character=utf-8");  
        response.setHeader("Cache-Control", "no-cache");
        
        String shipper = request.getParameter("shipper");
        String code = request.getParameter("code");
		
		KdApiSearchDemo api = new KdApiSearchDemo();
		try {
			String result = api.orderOnlineByJson(shipper, code);
			response.getWriter().write(result); 
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			response.getWriter().write("no"); 
		}
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
